package edu.zqu.course.framework.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * @Author 郭泽鹏
 * @Date 2020/6/21 15:00
 * @Description: 询当前用户的任务列表
 * @Version 1.0
 */

public class ActivitiTaskQuery {
    public static void main(String[] args) {
        /**
         * 1.得到ProcessEngine对象
         */
        ProcessEngineConfiguration configuration = ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti/activiti.cfg.xml","processEngineConfiguration");
        ProcessEngine processEngine = configuration.buildProcessEngine();
        /**
         * 2.得到TaskService对象
         */
        TaskService taskService = processEngine.getTaskService();

        /**
         * 3.根据流程定义的key,负责人assignee来实现当前用户的任务列表查询
         */
        List<Task> taskList = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee("zhangsan")
                .list();
        /**
         * 4.任务列表的展示
         */
        taskList.forEach((item)-> {
            System.out.println("流程实例ID"+item.getProcessInstanceId());
            System.out.println("任务ID"+item.getId());
            System.out.println("任务负责人"+item.getAssignee());
        });

        }
}
